﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<WebClient.Models.ViewModels.GroupViewModel>" %>

<%
    var selectedCity = "0";
    var selectedDistrict = "0";
    var selectedFoodType = "0";
%>

<center>
    <div id="div5">
        <% using (Ajax.BeginForm("Restaurant_SearchCity", "Home", new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "PartialDiv" }, new { @id = "MySubmitForm" }))
           { %>
            <div class="divsearch" id="fpcity" style="margin-right: 10px; padding-top: 10px;">
            <%
            var cities = new List<SelectListItem>();
            // Add first item : select your city
            cities.Add(new SelectListItem
            {
                Text = "Select your city",
                Value = "0"
            });
            // Select next city
            if (Model.AllCityModel != null)
            {
                foreach (var item in Model.AllCityModel.GetModel.LstObjModel)
                {
                    cities.Add(new SelectListItem
                    {
                        Text = item.Name,
                        Value = item.ID.ToString()
                    });
                }
            }
            if (Model.DistrictModelByCity != null)
            {
                selectedCity = ViewData["idcity"] == null ? "0" : ViewData["idcity"].ToString();
            }
            %>
            <%= Html.DropDownList("ListCityHeader", new SelectList(cities, "Value", "Text", selectedCity), new { @style = "font-size:14px; width:200px;", onChange = "submitForm()" })%>
            </div>
        <% } %>
        <div id="streets" class="divsearch" style="padding-top: 10px; margin-right: 10px;">
            <%
                var districts = new List<SelectListItem>();
                // Add first item : select your city
                districts.Add(new SelectListItem
                {
                    Text = "Select your district",
                    Value = "0"
                });
                // Select next city
                if (Model.DistrictModelByCity != null)
                {
                    if (selectedCity != "0")
                    {
                        foreach (var item in Model.DistrictModelByCity.GetModel.LstObjModel)
                        {
                            districts.Add(new SelectListItem
                            {
                                Text = item.Name,
                                Value = item.ID.ToString()
                            });
                        }
                        selectedDistrict = ViewData["iddistrict"] == null ? "0" : ViewData["iddistrict"].ToString();
                    }
                }
            %>
            <%= Html.DropDownList("ListDistrictHeader", new SelectList(districts, "Value", "Text", selectedDistrict), new { @style = "font-size:14px; width:200px;", onChange = "onSelectedIndexChanged_DistrictHeader()" })%>
        </div>
        <div id="Div8" class="divsearch" style="padding-top: 10px; margin-right: 10px;">
            <%
                var foodtypes = new List<SelectListItem>();
                // Add first item : select your city
                foodtypes.Add(new SelectListItem
                {
                    Text = "Pick your food",
                    Value = "0"
                });
                // Select next city
                if (Model.FoodTypeModel != null)
                {
                    foreach (var item in Model.FoodTypeModel.GetModel.LstObjModel)
                    {
                        foodtypes.Add(new SelectListItem
                        {
                            Text = item.Name,
                            Value = item.ID.ToString()
                        });
                    }
                    selectedFoodType = ViewData["idfoodtype"] == null ? "0" : ViewData["idfoodtype"].ToString();
                }
            %>
            <%= Html.DropDownList("ListFoodTypeHeader", new SelectList(foodtypes, "Value", "Text", selectedFoodType), new { @style = "font-size:14px; width:200px;", onChange = "onSelectedIndexChanged_FoodTypeHeader()" })%>
        </div>
    </div>
</center>